package com.example.demo.controller;

import com.example.demo.dto.dictionary.DictionaryDto;
import com.example.demo.entity.Dictionary;
import com.example.demo.service.IDictionaryService;
import com.example.demo.utils.result.Result;
import com.example.demo.utils.result.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("dictionary")
public class DictionaryController extends BaseController  {

    @Autowired
    IDictionaryService dictionaryService;

    @PostMapping("selectListByParentId")
    public Result selectListByParentId(@RequestBody DictionaryDto dictionaryDto){
        Integer parentId = dictionaryDto.getParentId();
        List<Dictionary> dictionaryList = dictionaryService.selectListByParentId(parentId).orElse(new ArrayList<>());

        return ResultUtils.success(dictionaryList);
    }
}
